import java.sql.*;
import java.util.Scanner;

public class log_in {

    public static boolean user_pp(String name,String word) throws SQLException {
        Connection conn=JDBC.getConnection();
        String sql="SELECT * FROM User WHERE name='"+name+"' AND password='"+word+"'";
        PreparedStatement ps=null;
        if (conn != null) {
            ps=conn.prepareStatement(sql);
        }
        ResultSet set=null;
        if (ps != null) {
            set=ps.executeQuery();
        }
        return set != null && set.next();
    }
    public static void denglu() throws SQLException {
        System.out.println("*******************************");
        System.out.println("************账号登录************");
        System.out.println("*******************************");
        Scanner sc=new Scanner(System.in);
        System.out.println("输入用户名:");
        String name=sc.next();
        System.out.println("输入登录密码密码:");
        String word=sc.next();
        if(user_pp(name,word)){
            System.out.println("登录成功");
            used_cars.carzhanshi();
        }else{
            System.out.println("登录失败");
        }
    }
}
